;THIS PROGRAM BOOTS AND PUTS UP A COLOR PATTERN ON THE SCREEN.

.ORG	$8000			;CHANGE THIS ORG TO $8000 FOR 32K GAMES,
				;USE $C000 FOR 16K GAMES.

BOOT:	SEI			;DISALLOW IRQ INTERRUPTS
	CLD
	LDX	#$FF
	TXS			;SET UP THE STACK

  	LDA	#$00		;ENABLE DOUBLE WIDE SPRITES, USE CHAR SET 1
	STA	$2000		;AND DISABLE NMI INTS.

	JSR	VERT_WAIT
	JSR	VERT_WAIT
	JSR	VERT_WAIT

;FILL THE BACKGROUND WITH EVERY POSSIBILITY.

	LDA	$2002		;RESET ADDRESS LATCH
	LDA	#6
	STA	$2001
	LDA	#$20
	STA	$2006
	LDA	#0		
	STA	$2006
	LDX	#208

F10:	TXA
	STA	$2007
	STA	$2007
	STA	$2007
	STA	$2007
	DEX			
	BNE	F10

	LDY	#32

F20:	TXA
	STA	$2007
	STA	$2007
	STA	$2007
	STA	$2007
	DEX
	DEY			
	BNE	F20

;PUT EVERY POSSIBLE PALETTE ON EACH CHAR

	LDA	$2002		;RESET ADDRESS LATCH
	LDA	#6
	STA	$2001
	LDA	#$23
	STA	$2006
	LDA	#$C0
	STA	$2006

	LDX	#60
  	LDA	#%00011011

P10:	STA	$2007		;NOW STORE THE PALETTES
	DEX	
	BNE	P10

;SET THE PALETTE REGISTERS

	LDA	$2002		;RESET ADDRESS LATCH
	LDA	#6
	STA	$2001
	LDA	#$3F
	STA	$2006
	LDA	#0		;ADDRESS ALL EVEN BYTES
	STA	$2006

	LDA	#$0F
	STA	$2007		;3F00

	LDA	#$11
	STA	$2007		;3F01

	LDA	#$14
	STA	$2007		;3F02

	LDA	#$05
	STA	$2007		;3F03

	LDA	#$3D
	STA	$2007		;3F04

	LDA	#$06
	STA	$2007		;3F05

	LDA	#$17
	STA	$2007		;3F06

	LDA	#$16
	STA	$2007		;3F07

	LDA	#$3D
	STA	$2007		;3F08

	LDA	#$29
	STA	$2007		;3F09

	LDA	#$0C
	STA	$2007		;3F0A

	LDA	#$1A
	STA	$2007		;3F0B

	LDA	#$3D
	STA	$2007		;3F0C

	LDA	#$15
	STA	$2007		;3F0D

	LDA	#$18
	STA	$2007		;3F0E

	LDA	#$22
	STA	$2007		;3F0F


	LDA	#0
	STA	$2006
	STA	$2006
	STA	$2005
	STA	$2005

	LDA	#$10
	STA	$2000

	LDA	#$0E
	STA	$2001		;ENABLE DISPLAY

VS20:	JMP	VS20	


;THIS SUB WILL WAIT FOR VERTICAL RETRACE ACTIVE.

VERT_WAIT:

V20:	LDA	$2002
	BPL	V20		;WAIT FOR VERTICAL RETRACE
	RTS

;HERE IS THE NMI VECTOR ROUTINE

NMI:  	RTI

;HERE IS THE IRQ VECTOR

IRQ:	JMP	BOOT
	RTI

.ORG	$FFFA		

;HERE ARE THE INTERRUPT AND BOOT VECTORS.  

	.FILL	 $FFFA-*,$00
	.DW	NMI
	.DW	BOOT
	.DW	IRQ
	.END